package com.itheima.reggie.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.reggie.common.R;
import com.itheima.reggie.entity.Orders;
import com.itheima.reggie.service.OrdersService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author solang
 * @date 2023-01-05 15:25
 */
@RestController
@RequestMapping("/order")
@Slf4j
public class OrdersContorller {
    @Autowired
    private OrdersService ordersService;
    @PostMapping("/submit")
    public R<String> submit(@RequestBody Orders orders){
        ordersService.insert(orders);
        return R.success("下单成功");
    }

    @GetMapping("/page")
    public R<List<Orders>> list(int page,int pageSize){
        log.info("page:{},PageSize:{}",page,pageSize);
        Page paInfo = new Page(page,pageSize);
        List<Orders> list = ordersService.list();
        return R.success(list);
    }
}
